export const useUserPinia = defineStore('user', () => {
  const token = ref<string>(null)
  const getToken = computed(() => token.value)
  function setToken(value: string) {
    token.value = value
  }

  const userInfo = reactive({
    id: null,
  })
  const getUserInfo = computed(() => name => name ? userInfo[name] : userInfo)

  async function getUserAuth(data?: any) {

  }
  async function removeUserInfo() {
    Object.keys(userInfo).forEach((key) => {
      userInfo[key] = null
    })
  }

  return {
    token,
    getToken,
    setToken,

    userInfo,
    getUserInfo,
    getUserAuth,
    removeUserInfo,

  }
}, {
  persist: [
    {
      pick: [
        'token',
      ],
    },
  ],
})
